//
//  gKhZJgJCTabbarController.swift
//  QRScan
//
//  Created by Qiang on 2018/3/25.
//  Copyright © 2018年 Qiang. All rights reserved.
//

import UIKit

class gKhZJgJCTabbarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        self.setupTabbar()
        self.addChildViewController()
    }
    private func setupTabbar(){
        let tabBarItem = UITabBarItem.appearance()
        let norDict = NSMutableDictionary(capacity: 0)
        norDict[NSAttributedStringKey.font] = UIFont.systemFont(ofSize: 10)
        norDict[NSAttributedStringKey.foregroundColor] = colorWithRGB(54, g: 88, b: 138, a: 1)
        tabBarItem.setTitleTextAttributes(norDict as? [NSAttributedStringKey : Any], for: .normal)
        
        let selDict = NSMutableDictionary(capacity: 0)
        selDict[NSAttributedStringKey.font] = UIFont.systemFont(ofSize: 10)
        selDict[NSAttributedStringKey.foregroundColor] = colorWithRGB(54, g: 88, b: 138, a: 1);
        tabBarItem.setTitleTextAttributes(selDict as? [NSAttributedStringKey : Any], for: .selected)
        UITabBar.appearance().backgroundColor = colorWithRGB(244, g:244, b:244, a: 1)
        
    }
    private func addChildViewController(){
        self.setUpChildController(childVc: HdwILdJCScanResultViewController(), norImage: UIImage(named:"JCScanNormal")!, selImage: UIImage(named: "JCScanSelected")!, title: "scan")
        self.setUpChildController(childVc: RDvhBvGeneratingViewController(), norImage: UIImage(named:"JCGeneratingNormal")!, selImage: UIImage(named:"JCGeneratingSelected")!, title: "generating")
        self.setUpChildController(childVc: GkLiJWSettingViewController(), norImage: UIImage(named:"JCSettingNormal")!, selImage: UIImage(named:"JCSettingSelected")!, title: "setting")
    }
    private func setUpChildController(childVc:UIViewController,norImage:UIImage,selImage:UIImage,title:String){
        let nav = UINavigationController(rootViewController: childVc)
        nav.navigationBar.barTintColor = colorWithRGB(54, g: 88, b: 138, a: 1)
        nav.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
        nav.navigationBar.tintColor = UIColor.white
        nav.tabBarItem = UITabBarItem(title: title, image: norImage.withRenderingMode(.alwaysOriginal), selectedImage: selImage.withRenderingMode(.alwaysOriginal))
        self.addChildViewController(nav)
    }
}
